<?php
/**
 * Created by PhpStorm.
 * User: 潘潘
 * Date: 2021/12/19
 * Time: 20:44
 */
require_once '../tools/DbTools.php';


//获取输入的值
$code=$_POST['code'];
$phone=$_POST['phone'];
$name=$_POST['name'];

//判断填入的信息是否完整
if(empty($code) || empty($phone) || empty($name)){
    echo '请输入完整信息！'.'<a href="openAccount.php">返回开户页面</a>';
    die;
}

//初始化数据库连接
DbTools::InitDb();
$sql="INSERT into accountinfo(AccountCode,AccountPhone,RealName,OpenTime) VALUES('$code','$phone','$name',NOW())";
$result=DbTools::noSelect($sql);

//判断开户是否成功
if(!$result['status']){
    echo '开户失败！'.'<a href="openAccount.php">返回开户页面<a/>';
    die;
}
echo '开户成功！'.'<a href="admin.php">返回管理员页面</a>';

//关闭数据库
DbTools::close();
